package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.PwdBean;
import com.lwj.liwanjia.impl.PwdView;
import com.lwj.liwanjia.model.SetPwdModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/11/30.
 */

public class SetPwdPresenter {
    private PwdView pwdView;
    private SetPwdModel setPwdModel;

    public SetPwdPresenter(PwdView pwdView) {
        this.pwdView = pwdView;
        setPwdModel = new SetPwdModel();
    }

    public void setPwd(String token, String pwd, String code,String phone) {
        if (pwdView != null) {
            setPwdModel.setPwd(token, pwd, code,phone, new Subscriber<PwdBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    pwdView.showError((Exception) e);
                }

                @Override
                public void onNext(PwdBean pwdBean) {
                    pwdView.setPwd(pwdBean);
                }
            });
        }
    }
}
